package xrz.com.jr.adapter;

import android.content.Context;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.joanzapata.android.BaseAdapterHelper;
import com.joanzapata.android.QuickAdapter;

import xrz.com.jr.R;
import xrz.com.jr.entity.Home;
import xrz.com.jr.utils.ImageUtils;
import xrz.com.jr.utils.ScreenUtil;

/**
 * Created by Administrator on 2016/7/28.
 */
public class Adapter_HomeGrid extends QuickAdapter<Home> {
    private int width;
    private Context context;

    public Adapter_HomeGrid(Context context) {
        super(context, R.layout.item_grid);
        this.context = context;
    }

    @Override
    protected void convert(BaseAdapterHelper helper, Home item) {
        width = ScreenUtil.getInstant().getDisWidth(context);
        ImageView imageView = helper.getView(R.id.imageview);
        LinearLayout Lin=helper.getView(R.id.lin_item);
        int Img_Width = (width/4) / 2 ;
        LinearLayout.LayoutParams params = new  LinearLayout.LayoutParams(Img_Width, Img_Width);
        params.gravity= Gravity.CENTER;
        imageView.setLayoutParams(params);
        ImageUtils.loadimg(imageView, item.getIcon());
        helper.setText(R.id.textview, item.getName());
    }
}
